home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Night Owl 6
/
Night Owl's Shareware - PDSI-006 - Night Owl Corp (1990).iso
/
038a
/
aplibs91.zip
/
HBDEMO.BAS
< prev
next >
Wrap
BASIC Source File
|
1991-07-02
|
64KB
|
1,819 lines
' ╔═════════════════════════════════════════════╗
' ║ THE NEW HB ALL-PURPOSE LIBRARY DEMO ║
' ║ FOR POWER-BASIC PROGRAMMERS ║
' ║ SPRING / SUMMER 1990 ║
' ║ Ver 2.5a, SPRING '91 ║
' ╚═════════════════════════════════════════════╝
' ┌─────────────────────────┐
' │ TO CREATE THIS DEMO OF │
' L O O K ======== >>> │ THE APLIB ROUTINES JUST │
' :) │ TYPE "makedemo" FROM │
' │ THE COMMAND LINE ! │
' └─────────────────────────┘
' NOTE: Due to wanting this to fit in one 64 K. source file, I'm
' removing some comments and advice lines. See doc file.
$COMPILE EXE
$LIB LPT ON,_
COM OFF, GRAPH OFF, FULLFLOAT OFF, IPRINT OFF
$STACK 3072
$ERROR ALL ON
$OPTION CNTLBREAK ON
%ScrnStackSize = 12
' Correct order: DIM Statements, $LINK statements, then PUBLIC statements.
$INCLUDE "APLIB-H.BAS"
' --------- DEFAULT COLORS ---------
%MonoMenu = %Blk + %Background * %Gry: %ColorMenu = %Wht + %Background * %Blu
%MonoBar = %Gry + %Background * %Blk: %ColorBar = %Ylo + %Background * %Red
%MonoWin = %Gry + %Background * %Blk: %ColorWin = %Blu + %Background * %Gry
%MonoFld = %Blk + %Background * %Gry: %ColorFld = %Ylo + %Background * %Red
%MonoBox = %Wht + %Background * %Blk: %ColorBox = %Wht + %Background * %Grn
%MonoScr = %Gry + %Background * %Blk: %ColorScr = %Cyn + %Background * %Blk
' ------------------------------------
$LINK "INIT-U.PBU"
$LINK "FENTRY-U.PBU"
$LINK "FIGDAT-U.PBU"
$LINK "BOXES-U.PBU"
$LINK "MENUS-U.PBU"
$LINK "MISC-U.PBU"
$LINK "NEW-U.PBU"
$INCLUDE "HBDEMO.PV"
' The *.PV files are lists of all the
' public variables in a program's units.
' Any time you change the EXTERNAL
' variables in your units, run
' PUBVARS.EXE and you will get a fresh,
' sorted list to include in the main
' file, like this.
SourceFile$ = "HBDEMO.BAS"
SourceDir$ = "." ' set up error handling
RDisk$ = ENVIRON$ ("TEMP") + ":" ' ┌──────────────────────────────────────┐
GoToSourceFile = %False ' <───────┤ If you use QEdit, set this var as │
ON ERROR GOTO Oops ' │ %True and you'll get automatic │
' │ search for runtime errors when │
' │ working from the command line -- │
' │ just like you do in the PB environm't│
' └──────────────────────────────────────┘
UsingButtons = %True
LocalAreaCode$ = "415"
Item% = 101 ' (starting # for demo checkbook entries)
CALL Initialize (%StarNX1000) ' see INIT-U.BAS for other printers
'
HomeDirec$ = CURDIR$ ("")
HomeDrive$ = GetCurrentDrive$
' =============================================== TITLE SCREEN
TopOfButtons = 19
DIM DYNAMIC ButtonMsg$ (1:5, 1:3)
DIM DYNAMIC Key2Alt (1:8)
ButtonMsg$ (1,1) = " Open"
ButtonMsg$ (1,2) = " QEDIT"
ButtonMsg$ (1,3) = " Alt-A"
Key2Alt (1) = 30 ' these are in QWERTY order
ButtonMsg$ (2,1) = "DIRECTORY"
ButtonMsg$ (2,2) = " MANAGER"
ButtonMsg$ (2,3) = " Alt-D"
Key2Alt (2) = 32
ButtonMsg$ (3,1) = "set mouse"
ButtonMsg$ (3,2) = " sens."
ButtonMsg$ (3,3) = " Alt-M"
Key2Alt (3) = 50
ButtonMsg$ (4,1) = " EXIT to"
ButtonMsg$ (4,2) = " DOS"
ButtonMsg$ (4,3) = " Alt-X"
Key2Alt (4) = 45
Buttons% = 4
GOSUB SetColors
COLOR ScrColor MOD 16, ScrColor \ 16 ' This breaks down an integer color
' attribute into foreground & backgrd
CLS
GOSUB Logo3 ' print a title in a box on screen
COLOR ScrColor MOD 16, ScrColor \ 16
' and next, open a Static Window
' (displays some data at run-time but doesn't let the user enter any) and
' displays some disk and system info in it.
' ===========================================================================
' USE OF THE SWW.EXE is a screen generator
' STATIC WINDOW and by processing DEMO.SW
' PAINT UTILITY gives the BASIC statements in
' SWW.EXE these lines to draw window
' and set up its static fields.
' The template files are similar
' to those use to make POPWINDOW
' designs, as described below.
' See OPENDEMO.SW for an example.
' ===========================================================================
$INCLUDE "opendemo.inc"
COLOR ScrColor MOD 16, ScrColor \ 16
LOCATE 24, 41: PRINT "note: use a mouse if you wish. L = yes.";
COLOR BarColor MOD 16, BarColor \ 16
LOCATE 25,1: CALL ClearLine ' SUB ClearLine erases screen from cursor
' position all the way to rt edge of scrn
PRINT " SOUND ON ?? ";
SoundOn = GetYesOrNo ' FUNCTION GetYesOrNo simply writes a
' "(y/n)" prompt to the screen and then
' awaits the user's pleasure. It is case
' insensitive & also Mousable. (L = Yes.)
GOSUB SetBeeps
If SoundOn THEN PLAY ArribaBeep$
Choice = 256 ' We don't want Choice, the
' menu return value, to be 0 at the start. A Choice value of 0 is used
' for a specific purpose: it means [Esc] was pressed in reponse to a
' pull-down menu.
' ==================================== PRINT MAIN MENU -- A BAR ACROSS TOP
MainMenu:
CHDRIVE (HomeDrive$)
CHDIR (HomeDirec$)
GOSUB SetColors ' set colors based on defaults
COLOR ScrColor MOD 16, ScrColor \ 16 ' or command line switches.
CLS
NextScrn2Pop = 1 ' Reset the screen stack pointer
' to 1. At this point the
' next screen we "push" (save) will
' be numbered 2 (I'm not using an 0)
LOCATE 24,1: GOSUB WipeLn
PRINT F1Help$;
' =============================================================================
'
' How to use "TOPMENU ()" -- The Horizontal Main Menu Procedure --
' -----------------------------------------------------------
'
' This procedure writes a list of choices across the top of the screen and
' allows the user to select from them by one of three methods: (1) Press the
' first letter of the desired choice (note that you can't have two choices
' starting with the same letter!) or (2) use the cursor arrows to highlight
' your choice and then press Enter (CR), or (3) if you have a Furry Friend,
' just click on your choice with the left button. (This is pretty much the
' way people expect a menu to behave!)
'
' Set it up with a DATA list of selection titles like the one following --
' follow w/ DATA END; don't forget to RESTORE to the label above the list.
' you can use less than a three line menu (to save screen space) but
' frankly I haven't used 2-line or 1-line TOPMENU's enough to even know
' whether they have bugs, so just use 3 for now. T$ should be the menu
' title if you want one, and after the CALL returns, will be set to the
' string chosen by the user or "HELP!" if F1 pressed. Mostly I just branch
' the program on the basis of TChoice, an integer showing which selection
' was made.
' =============================================================================
IF Choice > 0 THEN ' unless user has just backed out of a menu w/o selecting,
TChoice = 1 ' the return variable Choice will be > 0 and
GOSUB Logo2 ' the main menu will be reset to choice #1
END IF
TimeOut = 10
T$ = " HB's PowerBASIC Routines Library: the Demo " ' menu title
If SoundOn THEN PLAY LookitBeep$
DATA "POPWINDOW DEMO","FILES","MENUS & BOXES","OTHER DEMOS","QUIT/CONFIG"
DATA END
NumberOfLines = 3
DO
RESTORE MainMenu
CALL TOPMENU (NumberOfLines, TChoice, T$)
IF T$ = "HELP!" THEN
RESTORE MainMenuHelp
GOSUB HelpWindow
END IF
LOOP UNTIL T$ <> "HELP!"
CALL SCREENPUSH ' save this screen to memory ...
MainMenuScreen = NextScrn2Pop ' make a note of what number it is ...
SELECT CASE ButtonActive
CASE 0
IF TimeOut THEN GOTO ScreenBlank
ON TChoice GOTO OpenEntryWindow, FileSubmenu, MenuDemo,_
MiscDemos, QuitSubMenu
CASE 4
COLOR ScrColor MOD 16, ScrColor \ 16
CLS
CALL CloseFiles
CALL RestoreDOSScreen
END
CASE 3
CALL MouseControl (0, 0)
GOTO MainMenu
CASE ELSE
CALL QBox (20, %Center, 1, "YOU PICKED BUTTON " + STR$(ButtonActive), 0)
DELAY .5
CALL PressAKey
GOTO MainMenu
END SELECT
' ------------------ MAIN MENU CHOICE # 2: FILE SUBMENU ------------------
FileSubmenu:
' ============================================================================
' Notes: *** HOW TO USE: SUPERMENU () ***
' ===================
'
'Syntax:
'CALL SUPERMENU (MenuData$(), MenuRight, MenuDown, Choice, Title$, KeyPressed)
'
'
' MENU SETUP: THE MenuData$ ARRAY:
' Each choice on your menu is represented by one string element in
' this array. The decription of each choice -- for example, "LOAD",
' will start with the third character of this string. If you are
' specifying the hot-key for each choice put it into the first
' character -- set MenuData$ (1) as something like "L LOAD". To let
' the software number or letter the items in order for you, set
' MenuData$ as just " LOAD". (If there are <10 items, numbers
' are used rather than letters.) After the last menu item, you
' must set the next array element as "END".
' PASSING HELP LINES TO MENU: Set MenuHelpLine$() to contain lines (up
' to 80 chr long) to appear at screen bottom whenever the
' corresponding menu choice is highlighted.
' POSITION OF MENU ONSCREEN ETC.: MenuRight moves it right or left --
' MenuDown moves it -- you guessed it! 0,0 is top center. Errors are
' trapped. Vertical centering is gotten by setting MenuDown = 25.
' Usually set Choice = 1. Title$ is title of menu.
' *** AFTER MENU ROUTINE: Choice will hold the choice #. Title$ reset to "".
' MKeyPressed$ = the actual key used (if L. Mousebutton was used it
' simulates the CR key, i.e. CHR$(13)) -- or if [ESC] or a legal
' function key was pressed it contains "ESC", "PgDn", "PgUp", "F1",
' or "F2". (Right Mousebutton = "ESC".)
' ============================================================================
MenuData$(1) = "F Directory"
MenuData$(2) = "V View .BAS"
MenuData$(3) = "D View .DOC"
MenuData$(4) = "P Print DOC file"
MenuData$(5) = "C Copy files"
MenuData$(6) = "O Shell to DOS"
MenuData$(7) = "END"
MenuHelpLine$ (1) =_
"Using CALL DirFirst & DirNext (SUB's that get info direct from DOS)"
MenuHelpLine$ (2) = "this lets you read the source file HBDEMO.BAS"
MenuHelpLine$ (3) =_
"this lets you display the documentation accompanying HBLib"
MenuHelpLine$ (5) = "here a dummy function"
MenuHelpLine$ (6) = "this works -- if it can find COMMAND.COM & load it ..."
Title$ = ""
Choice = 1
PullDown = %Yes ' Make this a pulldown supermenu ...
UseRArrow = %Yes ' We want to be able to drag it either
UseLArrow = %Yes ' rt or left with arrow keys or rodent ...
MenuRight = -15
MenuDown = 2
CALL SUPERMENU (MenuData$(), MenuRight, MenuDown,_
Choice, Title$, KeyPressed)
DECR NextScrn2Pop ' we won't need to pop the previous screen
IF KeyPressed = %F1 THEN GOSUB MenuHelpScrn: GOTO FileSubMenu
IF KeyPressed = %LArrow THEN GOSUB MZap: GOTO OpenEntryWindow
IF KeyPressed = %RArrow THEN GOSUB MZap: GOTO MenuDemo
IF Choice = 0 THEN MainMenu
SELECT CASE LEFT$ (MenuData$ (Choice), 1)
CASE "F"
GOSUB Directory
GOTO MainMenu
CASE "V", "D"
If SoundOn THEN PLAY LookitBeep$
IF ColorDisplay THEN Color %Wht, %Blu ELSE COLOR %Gry, %Blk
CLS
IF Choice = 3 THEN File2View$ ="APLIB.DOC" ELSE File2View$ = "HBDEMO.BAS"
IF EXIST (File2View$) THEN ' uses function EXIST () ...
TxtFile = FREEFILE ' gets an available handle # ...
OPEN File2View$ FOR INPUT AS #TxtFile
Ln = 0
DO UNTIL EOF (TxtFile) OR FileError ' and views the file.
LINE INPUT #1, L$
INCR Ln
IF ColorDisplay THEN COLOR %Wht, %Blu ELSE COLOR %Gry, %Blk
PRINT LEFT$ (L$, 79)
IF CSRLIN = 23 THEN
IF ColorDisplay THEN Color %Blu, %Vlt ELSE COLOR %Blk, %Gry
PRINT STRING$ (80, 205);
CALL ClearLine
PRINT " WORLD'S MOST PRIMITIVE FILE VIEWER: File ";
PRINT File2View$; ", LINE "; Ln-21;
LOCATE 25,1, 0
CALL ClearLine
PRINT " PRESS [ESC] TO EXIT, [PG-UP] TO GO BACK TO LINE 1, ";
PRINT "ANY OTHER KEY TO GO ON";
DO: LOOP UNTIL INSTAT
K$ = INKEY$
IF K$ = CHR$ (27) THEN EXIT LOOP
IF K$ = CHR$ (0) + CHR$ (&H49) THEN
If SoundOn THEN PLAY TinyBeep$
CLOSE #TxtFile
OPEN File2View$ FOR INPUT AS #TxtFile
Ln = 0
END IF
IF ColorDisplay THEN COLOR %Wht, %Blu ELSE COLOR %Gry, %Blk
FOR N = 1 TO 22: LOCATE N, 1: CALL ClearLine: NEXT: LOCATE 1,1
END IF
LOOP
IF SoundOn THEN PLAY ArribaBeep$
CLOSE #1
ELSE
Msg$ = "DID NOT FIND FILE " + GetCurrentDir$ ("") + "\" + File2View$
CALL QBox (10, 20, 1, Msg$ , 0)
' QBox was written to put little dialog boxes
' onscreen -- but it turns out to very handy as a message box as well. This
' will print a box at position 10, 20 with this string in it and an answer
' field length of zero.
CALL PressAKey ' Little box says Press Any Key ... if mouse
END IF ' present it also suggests a click.
EXIT SELECT
CASE "O"
If SoundOn THEN PLAY LookitBeep$
IF ColorDisplay THEN COLOR %Ylo, %Red ELSE COLOR %Blk, %Gry
CLS
LOCATE 2,12: PRINT "TYPE `EXIT' TO RETURN TO PROGRAM"
SHELL
GOTO MainMenu
CASE "P"
GOSUB PrintDoc
GOTO MainMenu
CASE ELSE
GOTO FakeFunction
END SELECT
GOTO MainMenu
' -------------------- MAIN MENU CHOICE #3: MENU DEMOS ----------------
MenuDemo:
MenuData$ (1) = " Demo of MESSAGEBOX"
MenuData$ (2) = " Demo of QBOX"
MenuData$ (3) = " Demo of SUPERMENU"
MenuData$ (4) = " Hundred Items Menu"
MenuData$ (5) = " Menu of Files"
MenuData$ (6) = "END"
Choice = 1
PullDown = %Yes
UseRArrow = %Yes
UseLArrow = %Yes
CALL SUPERMENU (MenuData$ (), 0, 2, Choice, "", KeyPressed)
DECR NextScrn2Pop
IF KeyPressed = %Esc THEN MainMenu
IF KeyPressed = %F1 THEN GOSUB MenuHelpScrn: GOTO MenuDemo
IF KeyPressed = %LArrow THEN GOSUB MZap: GOTO FileSubMenu
IF KeyPressed = %RArrow THEN GOSUB MZap: GOTO MiscDemos
ON Choice GOSUB MessageBoxTest, QBoxTest, MoveAMenuII,_
HundredItemsMenu, MOFiles
' NOTE: if [Esc] was pressed, Choice = 0 and there's no GOSUB at all.
GOTO MainMenu
' ==================== MAIN MENU CHOICE # 4 -- MISC. SUBMENU
MiscDemos:
' set up menu lines & help lines ...
MenuData$ (1) = " ENTRY MODES" ' note that for this menu I've
MenuData$ (2) = " DATE ARITHMETIC" ' left two spaces in front of
MenuData$ (3) = " BEEPS" ' each choice. SUPERMENU will
MenuData$ (4) = " END" ' number them (or letter if > 9)
MenuHelpLine$ (1) = "many different types of line entries demonstrated"
MenuHelpLine$ (2) = "the all-knowing machine will tell you your age ..."
MenuHelpLine$ (3) =_
"this is a test-bed to invent, hear and save your own favorite Beeps ..."
MenuRight = 18 ' locate menu ...
MenuDown = 2
Choice = 1 ' start with first item highlighted ...
Title$ = "" ' no title ...
Choice = 1
UseRArrow = %Yes
UseLArrow = %Yes
PullDown = %Yes
CALL SUPERMENU (MenuData$(), MenuRight, MenuDown, Choice, Title$, KeyPressed)
DECR NextScrn2Pop ' we won't need to pop the previous screen
IF KeyPressed = %Esc THEN MainMenu
IF KeyPressed = %F1 THEN GOSUB MenuHelpScrn: GOTO MiscDemos
IF KeyPressed = %LArrow THEN GOSUB MZap: GOTO MenuDemo
IF KeyPressed = %RArrow THEN GOSUB MZap: GOTO QuitSubMenu
ON Choice GOSUB EnterDemo, DateTest, BeepTest
GOTO MainMenu
QuitSubMenu: ' ====================== MAIN MENU CHOICE #5: QUIT
MenuData$ (1) = "Y Exit to DOS"
IF SoundOn THEN
MenuData$ (2) = "S Sound Off"
ELSE
MenuData$ (2) = "S Sound On"
END IF
MenuData$ (3) = "E Fake ERROR"
MenuData$ (4) = "N Cancel"
MenuData$ (5) = "END"
MenuHelpLine$ (3) = "force an error just to see the error handling routine"
MenuHelpLine$ (4) = "don't quit after all ... "
Title$ = ""
Choice = 1
PullDown = %Yes
UseLArrow = %Yes
CALL SUPERMENU (MenuData$(), 40, 2, Choice, Title$, KeyPressed)
DECR NextScrn2Pop ' we won't need to pop the previous screen
IF KeyPressed = %Esc THEN MainMenu
IF KeyPressed = %F1 THEN GOSUB MenuHelpScrn: GOTO QuitSubMenu
IF KeyPressed = %LArrow THEN GOSUB MZap: GOTO MiscDemos
If SoundOn THEN PLAY LookitBeep$
IF CHOICE = 0 THEN
CALL SCREENPOP
GOTO MainMenu
ELSE
IF LEFT$ (MenuData$ (Choice), 1) <> "E" THEN COLOR 0,0:CLS:DECR NextScrn2Pop
END IF
IF Choice <> 0 THEN OldChoice = 1
SELECT CASE LEFT$ (MenuData$ (Choice), 1)
CASE "Y"
LastScrn:
CLS
CALL CloseFiles ' Take care of writing database files back if any...
DELAY 0.5
ON ERROR GOTO HarmlessError
CALL RestoreDOSScreen ' restore screen that was there to begin with;
LOCATE ,,0
' write a boxed Farewell Message on top
' of the restored screen -- really
' impress 'em!
DATA "Thank you for using", "the HB Library DEMO",""
DATA Program ends., Press something.
DATA END
' ===================================
' USING BOXMESSAGE ():
' You need a DATA list like this;
' use a RESTORE statement so the
' runtime system can find it;
RESTORE LastScrn ' set the margin ...
Margin = 1 ' set CornerLin & CornerCol or use
If SoundOn THEN PLAY TaskBeep$ ' %Center as we do here to center the
CALL SCREENPUSH ' window ... and it's ready.
' ===================================
CALL BOXMESSAGE (%Center, %Center, Margin)
GOSUB ClickOrStrike
CALL SCREENPOP ' erase the box and return control to DOS.
LOCATE OrigL, 1
END ' ================>> EXIT POINT
CASE "S"
SoundOn = NOT SoundOn
CASE "E"
ErrorMessage$ = "fake error generated from HBDEMO menus"
DO
CALL SCREENPUSH
EType$ = " "
CALL QBox_
(5,10,1,"D for DOS ERROR, P for PRINTER ERROR, O for OTHER ERROR ", 2)
COLOR FldColor MOD 16, FldColor \ 16
Msg$ = "AutoCap"
FieldSize = 1
CALL ENTERSTRING (EType$, FieldSize, Msg$)
' =============================================================================
' How to use SUB ENTERSTRING (Wkg$,FLength,Msg$)
' ----------------------------------------
' This routine provides a field at current corsor loc for the operator to
' enter data into. Wkg$ is the current value of the field. FLength = length
' of field. Msg$ may be "" or may hold the strings "Cap" for all uppercase,
' "Auto" for automatic entry when full, "UpOut" or "BackOut" if UpArrow or
' Left/ backspace keys are to be able to end entry. Tab and ShfTab also
' work.
'
' On exiting sub, Msg$ may be reset as Left, Auto, Up, Down, ESC or CR. At
' any time during string entry the operator can press [CR] or DOWN- ARROW
' to enter; [F2] is pressed for Database Function commands (Clear, Find,
' Next/Prev, View Notes, Save) implemented (see SUB FileFunctions)
'
' 2-4-89: Now supports: ^Y, ^T, and ^Arrow. Negative numbers not allowed
' unless Msg$ includes a "-" InsertStatus is a global.
' N.B.: OF COURSE THIS IS JUST A ONE-CHR STRING TO ENTER. I PUT THE DOC
' BLOCK HERE 'CAUSE IT'S THE F I R S T INSTANCE OF THIS CALL.
' THERE ARE MANY MORE-TYPICAL EXAMPLES TO FOLLOW ...
' ===========================================================================
CALL SCREENPOP
LOOP UNTIL EType$ = "O" OR EType$ = "P" OR EType$ = "D" OR Msg$ = "ESC"
ON ERROR GOTO Oops
IF Msg$ = "ESC" THEN MainMenu
SELECT CASE EType$
CASE "O"
ERROR 5
CASE "D"
JustDemonstratingOops = %True
ERROR 53
EXIT SELECT
CASE ELSE
ERROR 27
END SELECT
END SELECT
GOTO MainMenu ' here end the various pulldown menus. Next come major
' routines ... Starting with OpenEntryWindow (lifted, as you might guess,
' from my personal custom Checkbook Program).
OpenEntryWindow:
'===============================================================================
' ABOUT POPWINDOWS:
' Here's how to create a window for data entry like the one demonstrated
' here: (1) Create a plain-ASCII template file for your window and name
' it like WHATEVER.PW (See PWDEMO.PW for a sample).
' (2) Draw out the top and left side of the window box using the
' carat (^^^) symbol. Type in the field titles and then use a
' left bracket ("{") to show where you want each data entry field
' to start.
' (3) Under that type a backslash ("\") at the left margin, followed
' by a list of the following: First your name for the field, then
' a comma, and then IN QUOTES the mask string you want to use for
' the data in your field (according to the rules for the
' PRINT USING statement).
' (4) Now you need to use a utility PWW.EXE. Compile PWW.BAS to create
' it if you need to. Type PWW, followed optionally by the name
' of your POPWINDOW file (with or without its .PW extension). If
' you haven't screwed up, an INClude file will be created just
' like PWDEMO.INC, to include (or read into) your program !!
'===============================================================================
RESTORE OpenEntryWindow
$INCLUDE "CkWindow.inc" ' contains DATA statements
' to define the window.
CALL POPWINDOW
If SoundOn THEN PLAY LookItBeep$
'===============================================================================
' OK, now what's happened ?? First off, your data entry window has been
' opened (drawn) on the screen, using the attribute BoxColor; and the blank
' data fields have been added using FieldColor. Also a table has been created
' in memory consisting of several arrays to instantly reset the cursor to
' any of the fields in the window and find which mask string to use on that
' particular field. This job is done by PWSetUp (). Read on ...
'===============================================================================
' ____________________________
NewRec = %True
BeginEntry:
GetTypeOfTransaction:
COLOR ScrColor MOD 16, ScrColor \ 16
LOCATE 25,1: CALL ClearLine
LOCATE 24,1: CALL ClearLine: PRINT Esc2Q$; F1Help$;
COLOR FldColor MOD 16, FldColor \ 16
' create a SUPERMENU of these choices ...
MenuData$ (1) = "C CHECK"
MenuData$ (2) = "D DEPOSIT"
MenuData$ (3) = "A AUTO DEBIT"
MenuData$ (4) = "T TRANSFER"
MenuData$ (5) = "J ADJUSTMENT"
MenuData$ (6) = "END"
CALL SCREENPUSH
Choice = 1 ' start with first item highlighted ...
Title$ = "" ' no title ...
Choice = 1
UseRArrow = %Yes
PullDown = %Yes
MenuDown = 2
MenuRight = -40
CALL SUPERMENU (MenuData$(), MenuRight, MenuDown, Choice, Title$, KeyPressed)
IF KeyPressed = %RArrow THEN GOSUB MZap: GOTO FileSubMenu
IF KeyPressed = %F1 THEN GOSUB MenuHelpScrn: GOTO BeginEntry
IF Choice = 0 THEN
COLOR %Vlt, %Vlt: CLS
GOTO MainMenu
END IF
TypeOfTransferMenu:
IF Choice = 4 THEN
DATA FROM CHECKING TO SAVINGS,
DATA FROM SAVINGS TO CHECKING,
DATA END
' this is a POPMENU, the predecessor
' of SUPERMENU. Now SUB POPMENU ()
' is just a wrapper for SUPERMENU
RESTORE TypeOfTransferMenu ' so I don't have to convert all my
MLine$ = "type of transfer" ' old code. It uses READ intead of
Choice = 1 ' passing an array.
CALL POPMENU ("1", -12, 9, Choice, MLine$, Dum$)
CALL SCREENPOP
IF Choice = 0 THEN GOTO BeginEntry
IF ColorDisplay THEN COLOR %Ylo,%Red
IF Choice = 1 THEN TransactionType$ = "TRANSFER C-S" ELSE_
TransactionType$ = "TRANSFER S-C"
ELSE
CALL SCREENPOP
TransactionType$ = MID$ (MenuData$ (Choice), 3)
END IF
'===============================================================================
' OK, gentle hackfriend -- don't panic! What happens in the first data entry
' field in this dummy checkbook program, is that two successive menus are used
' as "pick lists" to get the data rather than having the user type it in. (If
' this isn't clear, try it out -- run HBDEMO.EXE -- and it should make
' a modicum of sense.)
'
' So here is that PWSetUp () call. It searches out a field name in the table
' I mentioned above to match the field description string (FldN$)
'===============================================================================
FldN$ = "TYPE OF TRANSACTION"
COLOR FldColor MOD 16, FldColor \ 16
KeyField = %False
CALL PWSetUp (FldN$,Tbl%)
' now the cursor should be in
' the right place and Tbl%
' should be the right item # in
' the array. Let's try it & see ...
PRINT USING FieldMask$(Tbl%); TransactionType$
' _______________________________________ WOW !!! NeatO !!
CheckNumberEntry:
COLOR %Blk, %Blk: LOCATE 23,1: CALL ClearLine
COLOR ScrColor MOD 16, ScrColor \ 16
LOCATE 25,1: CALL ClearLine: PRINT " "; F2Fun$; Up2B$; Esc2Q$;
LOCATE 24,1: CALL ClearLine: PRINT EnHelp$;
COLOR FldColor MOD 16, FldColor \ 16
FldN$ = "NUMBER": A# = Item%
CALL PWSetUp (FldN$,Tbl%)
IF RTRIM$ (TransactionType$) = "CHECK" THEN
KeyField = %True ' this clues in the FileFunctions menu
Msg$ = "F1 F2 UpOut"
' ENTERNUMBER () works a lot
CALL ENTERNUMBER (A#,"####",Msg$) ' like ENTERSTRING () except
' you specify a Mask String
' so it can do PRINT USING.
IF Msg$ = "HELP!" THEN GOSUB EDHelp: GOTO CheckNumberEntry
IF Msg$ = "Up" OR Msg$ = "ShfTab" GOTO GetTypeOfTransaction
Item% = A#
GOSUB F2orEscHandler
ELSE
PRINT " -- "
END IF
DateEntry:
LOCATE 25,1: CALL ClearLine: PRINT " "; Up2B$; Esc2Q$;
BXScreenSaved = %False
KeyField = %True
FldN$ = "DATE"
CALL PWSetUp (FldN$,Tbl%)
L = CSRLIN: C = POS
IF DateLastUsed$ = "" OR_
FigDate& (DateLastUsed$) = 0 THEN DateLastUsed$ = GetDate$
IF Msg$ <> "Up" AND Msg$ <> "ShfTab" OR_
FigDate& (TransactionDate$) = 0 THEN TransactionDate$ = DateLastUsed$
Msg$ = "N/AOK"
CALL RotaDate (TransactionDate$,Msg$)
' =========================================================================
' ROTADATE: This is the date entry routine where you can use the cursor
' keys to go ahead or back to the date you want. If you want you can
' also key in the date in the usual way ...
' =========================================================================
IF Msg$ = "HELP!" THEN GOSUB EDHelp: GOTO DateEntry
' FigDate returns a 0 if
' LOCATE L,C
' PRINT TransactionDate$
IF Msg$ = "Up" OR Msg$ = "ShfTab" GOTO CheckNumberEntry
GOSUB F2orEscHandler
DateLastUsed$ = TransactionDate$
ToFromWhomEntry:
COLOR ScrColor MOD 16, ScrColor \ 16
LOCATE 24,1: CALL ClearLine: PRINT EnHelp$;
LOCATE 25,1: CALL ClearLine: PRINT " "; F2Fun$; Up2B$; Esc2Q$;
COLOR FldColor MOD 16, FldColor \ 16
KeyField = %True
FldN$ = "TO/FROM"
CALL PWSetUp (FldN$,Tbl%)
X = CSRLIN: Y = POS
Msg$ = "F1F2UpOutCaps"
IF RTRIM$ (TransactionType$) = "AUTO DEBIT" THEN
ToFrom$ = "CASH FROM A.T.M."
ELSE
ToFrom$ = ""
END IF
CALL ENTERSTRING (ToFrom$,LEN(FieldMask$(Tbl%)),Msg$)
IF Msg$ = "HELP!" THEN GOSUB EDHelp: GOTO ToFromWhomEntry
IF Msg$ = "Up" OR Msg$ = "ShfTab" THEN GOTO DateEntry
GOSUB F2orEscHandler
KeyField = %False
IF Msg$ = "Up" THEN
GOTO DateEntry
ELSE
ToFrom$ = A$
END IF
EntAmt:
COLOR Ink2, Paper2
COLOR FldColor MOD 16, FldColor \ 16
LOCATE 25,1: CALL ClearLine: PRINT Up2B$; Esc2Q$;
FldN$ = "AMOUNT": Amt# = 0
CALL PWSetUp (FldN$,Tbl%)
Msg$ = "F2UpOut - "
CALL ENTERNUMBER (Amt#, FieldMask$(Tbl%), Msg$)
IAmtCents& = 100 * Amt#
IF Msg$ = "Up" OR Msg$ = "ShfTab" GOTO ToFromWhomEntry
IF Msg$ = "HELP!" THEN GOSUB EDHelp: GOTO EntAmt
GOSUB F2orEscHandler
SaveRecord:
COLOR %Wht,%Blk: LOCATE 24,1: CALL ClearLine: LOCATE 25,1: CALL ClearLine
LOCATE 24,9: PRINT "Note: THERE IS NO REAL SAVE RECORD FUNCTION -- DUMMY ONLY";
CALL SCREENPUSH
CALL QBox (19,30,1,"SAVE RECORD ?? ",3)
If SoundOn THEN PLAY LookitBeep$
CALL ENTERYESNO (Confirm) ' query if save to be done ...
CALL SCREENPOP
IF Confirm THEN
If SoundOn THEN PLAY TaskBeep$
DELAY 1.6
IF RTRIM$ (TransactionType$) = "CHECK" THEN INCR Item%
GOTO MainMenu
ELSE
GOTO BeginEntry
END IF
GOSUB SaveRecord
GOTO OpenEntryWindow
'___________________________________________________________________________
F2orEscHandler:
' Smart menu of choices appropriate to a database,
' such as SAVE, CLEAR, FIND, NEXT etc.
IF Msg$ = "F2" THEN
If SoundOn THEN PLAY LookitBeep$
SELECT CASE GetFileFunction$
CASE "C"
RETURN OpenEntryWindow
CASE "F"
RETURN FakeFunction
CASE "S"
RETURN SaveRecord
CASE ELSE
RETURN
END SELECT
ELSEIF Msg$ = "ESC" THEN
IF LTRIM$ (TransactionType$) <> "" THEN
CALL SCREENPUSH
CALL QBox (%Center, %Center, 1,_
"DO YOU WANT TO CLEAR THIS ENTRY AND RETURN TO MAIN MENU ?? ", 7)
IF NOT GetYesOrNo THEN CALL SCREENPOP: RETURN
END IF
NextScrn2Pop = MainMenuScreen
CALL SCREENPOP
RETURN MainMenu
END IF
RETURN
' ___________________________________________________________________
EnterDemo:
If SoundOn THEN PLAY LookitBeep$
IF ColorDisplay THEN
FldColor = %Ylo + %Background * %Red
ScrColor = %Ylo + %Background * %Blk
END IF
COLOR %Gry, %Blk
CLS
' Code to write Static Window {ENTERDEM} to Screen
' note: created by StatWindow Writer (SWW) from ENTERDEM.SW
COLOR BoxColor MOD 16, BoxColor \ 16
LOCATE 2, 9
PRINT "┌───────────────────────────────────────────────────────────┐"
LOCATE 3, 9
PRINT "│ A-P Library Demo : the Data Entry Routines │";
LOCATE 4, 9
PRINT "│ │";
LOCATE 5, 9
PRINT "│ (ENTERSTRING, ENTERNUM, ENTERDATE ETC.) │";
LOCATE 6, 9
PRINT "└───────────────────────────────────────────────────────────┘";
COLOR ScrColor MOD 16, ScrColor \ 16
' 07-06-1990, 23:46: end of StatWindow generated code for window {ENTERDEM}
LOCATE 24,1: CALL ClearLine: PRINT EnHelp$;
LOCATE 25,1: CALL ClearLine: PRINT F1Help$;
' ----------------------- First line: a plain entry, except no lower case:
StartEntries:
COLOR ScrColor MOD 16, ScrColor \ 16
O$ = "DEFAULT ENTRY" ' the string starts off as this
LOCATE 7,4: PRINT "REGULAR ENTRY, ALL CAPS w/ DEFAULT: "; ' leave cursor here
COLOR FldColor MOD 16, FldColor \ 16
Msg$ = "Caps F1" ' use all capitals, accept F1
FLength = 14
CALL ENTERSTRING (O$, FLength, Msg$)
COLOR ScrColor MOD 16, ScrColor \ 16
LOCATE 7,60: PRINT "Msg$ = ";Msg$;" " ' The value of Msg$
IF Msg$ = "HELP!" THEN GOSUB EDHelp: GOTO StartEntries ' on termination of
IF Msg$ = "ESC" GOTO DoneED ' SUB ENTER* shows
' what key was used
' to exit the sub.
' -------------------------- Next line: a string with Auto-CR when field full:
P$ = "Just keep typing ..."
AutoE:
COLOR ScrColor MOD 16, ScrColor \ 16
LOCATE 9,4: PRINT "ENTRY w/ AUTOMATIC TERMINATION: ";
COLOR FldColor MOD 16, FldColor \ 16
Msg$ = "F1 Auto"
CALL ENTERSTRING (P$, 20, Msg$)
COLOR ScrColor MOD 16, ScrColor \ 16
LOCATE 9,60: PRINT "Msg$ = ";Msg$;" "
IF Msg$ = "HELP!" THEN GOSUB EDHelp: GOTO AutoE
IF Msg$ = "ESC" GOTO DoneED
' ------------------------ This time up-arrow, ShfTab or left arrow will exit
LOCATE 25,1: PRINT Up2B$; F1Help$;
UpArrE:
COLOR ScrColor MOD 16, ScrColor \ 16
LOCATE 11,4: PRINT "ENTRY w/ UP-ARROW & BACK-OUT ENABLED: ";
COLOR FldColor MOD 16, FldColor \ 16
Msg$ = "F1UpOut BackOut"
CALL ENTERSTRING (Q$, 4, Msg$)
COLOR ScrColor MOD 16, ScrColor \ 16
LOCATE 11,60: PRINT "Msg$ = ";Msg$;" "
IF Msg$ = "HELP!" THEN GOSUB EDHelp: GOTO UpArrE
IF Msg$ = "Up" OR Msg$ = "Left" OR Msg$ = "ShfTab" GOTO AutoE
IF Msg$ = "ESC" GOTO DoneED
' ----------------------------- Let us not forget the main purpose of
' computers, counting beans! Here is money entry:
DollE:
COLOR ScrColor MOD 16, ScrColor \ 16
LOCATE 13, 4: PRINT "DOLLAR AMOUNT ENTRY: ";
COLOR FldColor MOD 16, FldColor \ 16
IF Msg$ <> "Up" THEN O# = 0: Msg$ = "F1UpOut"
' Here is ENTERNUMBER ().
CALL ENTERNUMBER (O#,"$####.##", Msg$) ' Note that the second argument is
' a mask string for PRINT USING.
COLOR ScrColor MOD 16, ScrColor \ 16
LOCATE 13,60: PRINT "Msg$ = ";Msg$;" "
IF Msg$ = "HELP!" THEN GOSUB EDHelp: GOTO DollE
IF Msg$ = "Up" OR Msg$ = "ShfTab" GOTO UpArrE
IF Msg$ = "ESC" GOTO DoneED
' ---------------------------- Now let's enter a decimal number.
NumE:
COLOR ScrColor MOD 16, ScrColor \ 16
LOCATE 15, 4: PRINT "NUMERIC ENTRY, 1 DECIMAL: ";
COLOR FldColor MOD 16, FldColor \ 16
Msg$ = "F1UpOut"
IF Msg$ <> "Up" THEN P# = 98.6
CALL ENTERNUMBER (P#,"##.#", Msg$)
COLOR ScrColor MOD 16, ScrColor \ 16
LOCATE 15,60: PRINT "Msg$ = ";Msg$;" "
IF Msg$ = "HELP!" THEN GOSUB EDHelp: GOTO NumE
IF Msg$ = "Up" OR Msg$ = "ShfTab" GOTO DollE
IF Msg$ = "ESC" GOTO DoneED
' --------------------------------- ... an SSA # ...
SSNE:
COLOR ScrColor MOD 16, ScrColor \ 16
LOCATE 17,4: PRINT "ENTER A SOCIAL SECURITY #: ";
COLOR FldColor MOD 16, FldColor \ 16
' IF Msg$ <> "Up" THEN SSN$ = ""
Msg$ = "F1UpOut"
CALL ENTERSSN (SSN$, Msg$)
COLOR ScrColor MOD 16, ScrColor \ 16
LOCATE 17,60: PRINT "Msg$ = ";Msg$;" "
IF Msg$ = "HELP!" THEN GOSUB EDHelp: GOTO SSNE
IF Msg$ = "Up" OR Msg$ = "ShfTab" GOTO NumE
IF Msg$ = "ESC" GOTO DoneED
' ------------------------------------
PhoneE:
COLOR ScrColor MOD 16, ScrColor \ 16
LOCATE 19,4: PRINT "ENTER A PHONE #: ";
COLOR FldColor MOD 16, FldColor \ 16
IF Msg$ <> "Up" THEN Phone$ = ""
Msg$ = "F1UpOut"
CALL ENTERPHONE (Phone$, Msg$)
COLOR ScrColor MOD 16, ScrColor \ 16
LOCATE 19,60: PRINT "Msg$ = ";Msg$;" "
IF Msg$ = "HELP!" THEN GOSUB EDHelp: GOTO PhoneE
IF Msg$ = "Up" OR Msg$ = "ShfTab" GOTO SSNE
IF Msg$ = "ESC" GOTO DoneED
' =========== NEW !!! ====================
CALL SCREENPUSH
CALL QBox (%Center, %Center, 3,_
"Here's the NEW phone # routine, FASTPHONE", 14)
CALL FASTPHONE (Phone2$, Msg$)
CALL PressAKey
CALL SCREENPOP
' ------------------------------------------------------- a date & a time ...
IF DateLastUsed$ = "" OR_
FigDate& (DateLastUsed$) = 0 THEN DateLastUsed$ = GetDate$
IF Msg$ <> "Up" AND Msg$ <> "ShfTab" OR_
FigDate& (D0$) = 0 THEN D0$ = DateLastUsed$
COLOR ScrColor MOD 16, ScrColor \ 16
LOCATE 21,4: PRINT "DATE (use arrows or numbers) ";
COLOR FldColor MOD 16, FldColor \ 16
Msg$ = "F1 N/Aok"
CALL ROTADATE (D0$, Msg$)
IF Msg$ = "Up" OR Msg$ = "ShfTab" GOTO PhoneE
IF Msg$ = "ESC" GOTO DoneED
COLOR ScrColor MOD 16, ScrColor \ 16
LOCATE 21,50: PRINT "TIME: ";
COLOR FldColor MOD 16, FldColor \ 16
T$ = ""
Msg$ = "F1UpOut"
CALL ENTERTIME (T$, Msg$)
IF Msg$ = "Up" OR Msg$ = "ShfTab" GOTO PhoneE
DoneED:
LOCATE 25,1: CALL ClearLine
IF NeedDCon THEN
PRINT " hit a key or click your beast to go on ...";
ELSE
PRINT " hit a key to go on ...";
END IF
COLOR ScrColor MOD 16, ScrColor \ 16
LOCATE 24,1: CALL ClearLine
GOSUB ClickOrStrike
GOTO MainMenu
EDHelp:
CALL SCREENPUSH
RESTORE EDHelp
CALL BOXMESSAGE (0, 0, 1)
GOSUB ClickOrStrike
CALL SCREENPOP
COLOR FldColor MOD 16, FldColor \ 16
RETURN
DATA "HELP FOR DATA ENTRY ROUTINES FROM HB'S ALL-PURPOSE POWER-BASIC TOOLBOX"
DATA ""
DATA "There is a space on the screen to type something into. The keyboard"
DATA "works the way you'd expect it to -- just like typing on a word"
DATA "processing program. If numbers are expected, no other keys will work."
DATA ""
DATA "Use [INSERT] key to switch between Insert Mode (Big Cursor) and "
DATA "Overstrike Mode. The [BACKSPACE] key works, & the [DELETE] key removes"
DATA "the letter the cursor is on. Press [ESC] to quit the entry process."
DATA ""
DATA "If there is something in the field to begin with and you start"
DATA "typing something else, the field clears. If you move the cursor"
DATA "around first, that doesn't happen. Use Ctrl-U to undo."
DATA ""
DATA " Use: [HOME] key, [END] key, Arrow Keys (Rt & Left) to move cursor "
DATA " Ctrl-Y to clear the line "
DATA " Ctrl-T to delete one word (to right) "
DATA " Ctrl-U to undo (restore original string) "
DATA " Ctrl-Rt or Left Arrow, (jumps to beginning of a word) "
DATA ""
DATA "See bottom line of screen for more help. PRESS ANY KEY "
DATA END
' ===========================================================================
DateTest:
If SoundOn THEN PLAY LookitBeep$
IF ColorDisplay THEN
Ink1 = %Blu: Paper1 = %Cyn: Ink2 = %Wht: Paper2 = %Red
ELSE
Ink1 = %Wht: Paper1 = %Blk: Ink2 = %Blk: Paper2 = %Gry
END IF
COLOR Ink1, Paper1: CLS
ON KEY (15) GOSUB Done
DO
DoB$ = ""
COLOR Ink1, Paper1
LOCATE 5,6: PRINT "Date of Birth :";
COLOR Ink2, Paper2
Msg$ = ""
CALL ENTERDATE (DoB$, Msg$)
LOOP UNTIL DoB$ <> "" ' if date entered not valid,
' the result string will be ""
COLOR Ink1, Paper1
LOCATE 7,6
W& = FigDate&(DoB$)
IF W& = 0 THEN RETURN MainMenu
PRINT "Days from 1-1-1900 (Julioid) = ";
COLOR Ink2, Paper2: PRINT W&
LOCATE 9,6: COLOR Ink1, Paper1
PRINT "Converting Back to Date = ";
COLOR Ink2, Paper2: PRINT WriteDate$(W&)
LOCATE 10,6
COLOR Ink1, Paper1: PRINT " (This Date was a ";
COLOR Ink2, Paper2: PRINT WkDay$(W&);
COLOR Ink1, Paper1: PRINT " )."
Today$ = GetDate$ ' a function ...
LOCATE 12,6: COLOR Ink1, Paper1: PRINT "Today is ";
COLOR Ink2, Paper2
PRINT Today$
LOCATE 14,6: COLOR Ink1, Paper1: PRINT "YOUR AGE IS: ";
COLOR Ink2, Paper2
PRINT YearsSince (DoB$)
BDay$ = DoB$: MID$ (Bday$,7) = RIGHT$ (Today$,2)
N = FigDate& (BDay$) - FigDate& (Today$)
LOCATE 16,6: COLOR Ink1, Paper1
SELECT CASE N
CASE 0
L = CSRLIN: C = POS
COLOR Ink1+16, Paper1
PRINT "HAPPY BIRTHDAY !!"
LOCATE ,,0
PLAY "O2 G8 G16 A4 G4 O3 C4 O2 B2": DELAY 2
COLOR Ink1, Paper1: LOCATE L,C,1
PRINT "HAPPY BIRTHDAY !!"
CASE > 0
PRINT "Your BIRTHDAY is only ";N;" days from today !"
If SoundOn THEN PLAY TaskBeep$
CASE < 0
PRINT "Your BIRTHDAY was ";ABS(N);" days ago."
If SoundOn THEN PLAY TaskBeep$
END SELECT
LOCATE 25,1: CALL ClearLine
CALL PressAKey
GOSUB Done
Done:
RETURN MainMenu
'__________________________________________________________________________
Logo2:
DATA HB's ALL-PURPOSE LIBRARY DEMO, For POWER BASIC, SPRING 1991, END
RESTORE Logo2
CALL BOXMESSAGE (0,0,1)
RETURN
Logo3:
RESTORE Logo2
CALL BOXMESSAGE (1,1,1)
RETURN
'__________________________________________________________________________
SUB CloseFiles PUBLIC
' What normally has to be done here, in a database program, is the
' index file closures (writing back data). If the program just crashes
' out to DOS, thus automatically closing all files at the DOS level,
' the index files will have been corrupted.
Dummy = IsRodent ' also reset your furry friend if any ...
END SUB
' ______________________________________________________________________
HarmlessError:
L00 = CSRLIN: C00 = POS
CALL SCREENPUSH
FlaskBox = %True
CALL QBox (%Center, %Center, 1, "ERROR " + STR$(ERR) + " @ " +_
STR$(ERADR), 0)
CALL PressAKey
CALL SCREENPOP
LOCATE L00, C00
RESUME NEXT
FakeFunction:
COLOR %LCyn, %Blu
If SoundOn THEN PLAY LookitBeep$
CLS
LOCATE 10,10,0:PRINT "This function will of course be brilliantly implemented"
DELAY .5
LOCATE 12, 11: PRINT "by you, the creator of your own magnificent applications
DELAY .5
LOCATE 14, 13: PRINT "using Power Basic and this humble Library."
If SoundOn THEN PLAY ArribaBeep$
CALL PressAKey
GOTO MainMenu
'____________________________________________________________________________
' ======================================================================
$SEGMENT
' ======================================================================
Directory:
' this worked under PB 2.0; it doesn't
DIM DYNAMIC ListOfDirectories$ (32) ' use the DIR$ function introduced in
CALL QBox (5,36,1,"FileSpec ?? ", 20) ' version 2.1. Instead it uses DirFirst
COLOR FldColor MOD 16, FldColor \ 16 ' and DirNext from MISC-U.PBU, which
M$ = "*.*" ' can also return file size, date etc.
Msg$ = "Cap"
CALL ENTERSTRING (M$, 20, Msg$)
IF Msg$ = "ESC" THEN ERASE ListOfDirectories$: RETURN
U$ = "File \ \ saved \ \ at \ \ -- "
M$ = FQFileSpec$ (M$)
Heading$ = "HB Custom Directory of " + M$
Heading$ = LEFT$ (Heading$, 80)
COLOR %Cyn, %Blk: CLS: LOCATE 1, 41-LEN(Heading$)\2: PRINT Heading$
Fls% = 0
FlName$ = M$
CALL DirFirst (FlName$, FileSize&, DateCode&, TimeCode&)
IF FlName$= "" THEN
CALL QBox (11, 30, 1, "No file "+ M$ +" found", 0)
CALL PressAKey
ERASE ListOfDirectories$
RETURN
ELSE
INCR Fls%
GOSUB PrDir
DO
CALL DirNext (FlName$, FileSize&, DateCode&, TimeCode&)
IF FlName$ = "" THEN EXIT LOOP
GOSUB PrDir
INCR Fls%
IF CSRLIN > 23 THEN
COLOR %Cyn, %Blk
IF NeedDCon THEN
PRINT " ... PRESS ANY KEY (OR MOUSEBUTTON) TO GO ON";
ELSE
PRINT " ... PRESS ANY KEY TO GO ON";
END IF
T& = TIMER
DO: K$ = INKEY$: LOOP UNTIL K$ <> "" OR MouseClicked OR TIMER - T& > 4
IF K$ = CHR$ (27) THEN GOTO DoneDirectory
COLOR %Cyn, %Blk: CLS
LOCATE 1, 41-LEN(Heading$)\2: PRINT Heading$
END IF
LOOP
PRINT
COLOR %Cyn, %Blk: PRINT Fls% ;"Files found"
END IF
IF RIGHT$ (M$, 3) = "*.*" THEN ' only show subdirectories if a full
PRINT ' directory was listed
COLOR %Wht, %Blk
PRINT STRING$ (80, 205);
PRINT
PRINT "Subdirectories of "; M$;
N = 1: D% = 1
DO WHILE (ListOfDirectories$ (N)) <> ""
PRINT
IF MID$ (ListOfDirectories$ (N), 2, 1) <> "." THEN
PRINT USING " \ \ (directory)"; ListOfDirectories$ (N);
INCR D%
END IF
INCR N
LOOP UNTIL INKEY$ <> ""
IF D% = 1 THEN PRINT " None"
END IF
CALL PressAKey
DoneDirectory:
ERASE ListOfDirectories$
D% = 0
RETURN
PrDir:
IF ColorDisplay THEN
COLOR 2 + (7 * (CSRLIN - 2*(CSRLIN\2))), 0
ELSE
COLOR (7 * (CSRLIN - 2*(CSRLIN\2))), 7 - (7 * (CSRLIN - 2*(CSRLIN\2)))
END IF
IF LEFT$ (FlName$, 1) = "<" THEN
INCR D%
ListOfDirectories$ (D%) =FlName$
ELSE
PRINT USING U$; FlName$, DecodeDate$ (DateCode&), DecodeTime$ (TimeCode&);
IF FileSize& < 1024 THEN
PRINT USING " #### bytes "; FileSize&
ELSE
PRINT USING "###.# KB "; FileSize& / 1024
END IF
END IF
RETURN
MoveAMenuII:
S = NextScrn2Pop
NextScrn2Pop = 1
CALL SCREENPOP
NextScrn2Pop = S
DELAY 1
RANDOMIZE TIMER
FOR Word = 1 TO 50
LOCATE INT (1+RND*25), INT (1+RND*61)
COLOR INT (1+RND*15), 0: PRINT "Important Data";
DELAY .05
NEXT Word
MenuColor = %Blk + %Background * %Gry
BarColor = %Ylo + %Background * %Grn
D = 3: R = -4
' menu lines are set up (D,R,L & Q will be the HotKeys) ...
MenuData$(1) = "U UP"
MenuData$(2) = "D DOWN"
MenuData$(3) = "R RIGHT"
MenuData$(4) = "L LEFT"
MenuData$(5) = "Q QUIT"
MenuData$(6) = "END"
Choice = 1
DO
Title$ = "MOVE ME" ' title
MenuRight = R
MenuDown = D
CALL SCREENPUSH
CALL SUPERMENU (MenuData$ (), MenuRight, MenuDown, Choice, Title$, Ky%)
CALL SCREENPOP
If SoundOn THEN PLAY TinyBeep$
SELECT CASE Choice
CASE 1
IF D > 0 THEN DECR D,2
CASE 2
IF D < 30 THEN IF D = 3 THEN INCR D,1 ELSE INCR D,2
CASE 3
IF R < 40 THEN INCR R,4
CASE 4
IF R > -40 THEN DECR R,4
END SELECT
IF ColorDisplay THEN
COLOR 15,5
ELSE
COLOR 0,7
END IF
LOCATE 25,3,0
PRINT "ARGUMENTS: Choice = ";Choice;"MenuDown = ";D;
PRINT " -- ";"MenuRight = ";R;
IF Ky% = %F1 THEN GOSUB MenuHelpScrn
IF Ky% = %F2 THEN LOCATE 23,1: COLOR 14,7: PRINT " F2 Pressed! "
LOOP UNTIL Choice = 5 OR Ky% = %Esc
GOSUB SetColors
RETURN
HundredItemsMenu:
CALL SCREENPUSH ' a multipage menu ...
RANDOMIZE TIMER
StartScreen = NextScrn2Pop
REDIM T$ (1:100)
MenuPages = 7
DO
IF ColorDisplay THEN
COLOR 0, RND * 8: CLS
ELSE
LOCATE 1,1
FOR L = 1 TO 25: PRINT STRING$ (80, 176);: NEXT
END IF
COLOR %Ylo, %Grn
MenuPage = 1
Choice = 1
DATA "Hundred Items", "Menu", "====", Use PG-DN or just
DATA drag bar down past, last line to see, "more choices"
DATA END
RESTORE HundredItemsMenu
CALL BOXMESSAGE (2, 1, 1)
FOR I = 1 TO 100
T$ (I) = USING$ (" This is menu item ### ", I)
NEXT
DO
FOR I = 1 TO 16
IF (MenuPage - 1) * 16 + I > 100 THEN
MenuData$ (I) = "END"
ELSE
MenuData$ (I) = T$ ((MenuPage - 1) * 16 + I)
END IF
NEXT
MenuData$ (17) = "END"
MenuRight = 6 * MenuPage -20
MenuDown = MenuPage - 1
Title$ = "PgUp/Pg-Dn for more"
IF MenuPage > 1 THEN UsePgUp = %Yes
IF MenuPage < 7 THEN UsePgDn = %Yes
CALL SUPERMENU (MenuData$ (), MenuRight, MenuDown, Choice, Title$, Ky%)
SELECT CASE Ky%
CASE %PgUp
DECR MenuPage
CALL SCREENPOP
Choice = 16
CASE %PgDn
INCR MenuPage
CALL SCREENPUSH
Choice = 1
CASE %F1
GOSUB MenuHelpScrn
END SELECT
LOOP UNTIL Ky% = %Esc OR Ky% = %CR
NextScrn2Pop = StartScreen
CALL SCREENPOP
LOOP UNTIL Ky% = %Esc
ERASE T$
RETURN MainMenu
' -------------------------------------------------------------------
MenuHelpScrn:
CALL SCREENPUSH
RESTORE MenuHelpScrn
DATA "WHAT DOES THIS MENU DO ?? -- Not much really. After all, this whole"
DATA "program is nothing but a demo."
DATA ""
DATA "IN THAT CASE, HOW DO I USE A MENU LIKE THIS ??"
DATA " I thought you'd never ask! Well, you can use ..."
DATA "(1) THE ONE KEY METHOD: Just find which item on the menu you want."
DATA "There will be a letter or number at the start of the"
DATA "item. Just press it and that's all."
DATA "(2) THE CURSOR KEY METHOD: Use the up or down cursor / arrow keys"
DATA "to move the highlighted bar to your selection, then"
DATA "press the ENTER key."
DATA "(3) THE PLASTIC PEST METHOD: Your mouse can make the choice you want!"
DATA "You don't see a mouse cursor but don't panic. Just drag the"
DATA "highlighted bar to your choice; then click the left button"
' NOTE: Other mouse button modes are supported. See the
' lines in MENUS-U that refer to LBPresses =
' and LBReleases (presently line # 460).
DATA ""
DATA "TO CANCEL THE MENU (Not make a choice):"
DATA "Press the Escape key, or the right mouse button. (You can even press"
DATA "the right button while you hold the left one -- or right after you"
DATA "let it go.)"
DATA END
CALL BOXMESSAGE (%Center, %Center, 0)
GOSUB ClickOrStrike
CALL SCREENPOP
RETURN
' -------------------------------------------------------------------------
BeepTest:
LOCATE 22,1
IF ColorDisplay THEN
Ink1 = %Blu: Paper1 = %Cyn: Ink2 = %LCyn: Paper2 = %Blu
ELSE
Ink1 = %Gry: Paper1 = %Blk: Ink2 = %Blk: Paper2 = %Gry
END IF
DELAY .7: If SoundOn THEN PLAY LookitBeep$
DO
IF CSRLIN > 20 THEN
COLOR Ink1, Paper1: CLS
COLOR Ink2, Paper2
LOCATE 1,22: PRINT " HB BEEP-TESTING ENVIRONMENT, V. 1.0 "
LOCATE 22,1: CALL ClearLine
LOCATE 23,1: CALL ClearLine
PRINT " Use syntax for PLAY as in BASICA and ";
PRINT "PowerBasic, e.g. O0 G2 A4 B-4 P4 G4"
LOCATE 24,1: CALL ClearLine
COLOR Ink1, Paper1
LOCATE 3,1
END IF
PRINT " PLAY ";CHR$(34);SPACE$(45);CHR$(34);
LOCATE CSRLIN, 8
Msg$ = "Auto Caps"
CALL ENTERSTRING (A$, 45, Msg$)
IF Msg$ = "ESC" OR A$ = "" THEN
PRINT " QUIT ?? ";
Quit = GetYesOrNo
IF Quit THEN
EXIT LOOP
ELSE
GOTO There
END IF
ELSE
ON ERROR GOTO Clunker
IF A$ <> "" THEN PLAY A$
ON ERROR GOTO Oops
LOCATE (CSRLIN), 56
PRINT "Print It ?";
Yes = GetYesOrNo
IF Yes THEN
INPUT " Comment ? ",B$
L = CSRLIN
COLOR 16+Ink2, Paper2
LOCATE 25,3,0: CALL ClearLine: PRINT "PRINTING ...";
LPRINT "From HB PowerBasic Beep Tester, ";GetDate$;":"
LPRINT " Name: ";B$;" -- PLAY ";CHR$(34);A$;CHR$(34)
LOCATE 25,1,1: CALL ClearLine
COLOR Ink1, Paper1
LOCATE L+1, 1
ELSE
PRINT
END IF
END IF
There:
LOOP
RETURN
Clunker:
PLAY "O1 C2"
A$ = ""
RESUME NEXT
MessageBoxTest:
COLOR ScrColor MOD 16, ScrColor \ 16
CLS
CALL QBox (3, %Center, 1, "DEMO OF MESSAGE WINDOWS (TRY TO MAKE IT FAIL!)", 0)
COLOR ScrColor MOD 16, ScrColor \ 16
LOCATE 10, 50: PRINT "... 0 = Horiz. Centered Box"
LOCATE 10,5: PRINT "LEFT UPPER CORNER AT COLUMN ";
COLOR FldColor MOD 16, FldColor \ 16
CALL ENTERNUMBER (CCol#, "###", Msg$)
IF Msg$ <> "CR" THEN RETURN MainMenu
COLOR ScrColor MOD 16, ScrColor \ 16
LOCATE 12, 50: PRINT "... 0 = Vert. Centered Box"
LOCATE 12,5: PRINT "LEFT UPPER CORNER AT ROW ";
COLOR FldColor MOD 16, FldColor \ 16
CALL ENTERNUMBER (CLin#, "###", Msg$)
IF Msg$ <> "CR" THEN RETURN MainMenu
COLOR ScrColor MOD 16, ScrColor \ 16
LOCATE 14,5: PRINT " MARGIN ? ";
COLOR FldColor MOD 16, FldColor \ 16
CALL ENTERNUMBER (Marg#, "#", Msg$)
IF Msg$ <> "CR" THEN RETURN MainMenu
Margin = MIN (CINT(Marg#), 3)
COLOR ScrColor MOD 16, ScrColor \ 16
LOCATE 16,5: PRINT "HOW LONG SHALL WE MAKE THE TEXT LINES ? ";
COLOR FldColor MOD 16, FldColor \ 16
CALL ENTERNUMBER (LinL#, "###", Msg$)
IF Msg$ <> "CR" THEN RETURN MainMenu
DO
COLOR ScrColor MOD 16, ScrColor \ 16
LOCATE 18,5: PRINT " ... AND HOW MANY LINES ? ";
COLOR FldColor MOD 16, FldColor \ 16
CALL ENTERNUMBER (LinsNum#, "###", Msg$)
IF Msg$ <> "CR" THEN RETURN MainMenu
LOOP UNTIL LinsNum# > 0
TenChr$ = "<Ten Chrs>"
Digital$ = "123456789"
N = INT (LinsNum#)
L = INT (LinL#)
Text4Box$ = REPEAT$ (L \ 10, TenChr$) + LEFT$ (Digital$, L MOD 10)
DIM DYNAMIC T$ (1:N)
FOR I = 1 TO N
T$(I) = Text4Box$
NEXT
CALL BOXMESSAGE2 (CINT (CLin#), CINT (CCol#), Margin, T$(), N, L)
CALL PressAKey
CLS
ERASE T$
RETURN
QBoxTest:
COLOR ScrColor MOD 16, ScrColor \ 16
CLS
CALL QBox (3, %Center, 1, "DEMO OF DIALOG BOX (TRY TO MAKE IT FAIL!)", 0)
FOR Oof = 1 TO 80 STEP 10: LOCATE 1, Oof: PRINT "|";: NEXT
COLOR ScrColor MOD 16, ScrColor \ 16
LOCATE 10, 50: PRINT "... 0 = Horiz. Centered Box"
LOCATE 10,5: PRINT "LEFT UPPER CORNER AT COLUMN ";
COLOR FldColor MOD 16, FldColor \ 16
CALL ENTERNUMBER (CCol#, "###", Msg$)
IF Msg$ <> "CR" THEN RETURN MainMenu
COLOR ScrColor MOD 16, ScrColor \ 16
LOCATE 12, 50: PRINT "... 0 = Vert. Centered Box"
LOCATE 12,5: PRINT "LEFT UPPER CORNER AT ROW ";
COLOR FldColor MOD 16, FldColor \ 16
CALL ENTERNUMBER (CLin#, "###", Msg$)
IF Msg$ <> "CR" THEN RETURN MainMenu
Lins# = INT (Lins#)
COLOR ScrColor MOD 16, ScrColor \ 16
LOCATE 14,5: PRINT " ONE LINE BOX OR THREE LINE BOX ?? ";
COLOR FldColor MOD 16, FldColor \ 16
L = CSRLIN: C = POS
DO
LOCATE L, C
Lins$ = " "
CALL ENTERSTRING (Lins$, 1, Msg$)
Lins = VAL (Lins$)
LOOP UNTIL Lins = 1 OR Lins = 3
IF Msg$ <> "CR" THEN RETURN MainMenu
COLOR ScrColor MOD 16, ScrColor \ 16
LOCATE 16,5: PRINT "ENTER TEXT LINE: ";
COLOR FldColor MOD 16, FldColor \ 16
IF Prompt$ = "" then Prompt$ = "Sample Prompt"
CALL ENTERSTRING (Prompt$, 40, Msg$)
IF Msg$ <> "CR" THEN RETURN MainMenu
COLOR ScrColor MOD 16, ScrColor \ 16
LOCATE 18,5: PRINT "LENGTH OF ANSWER FIELD ? ";
COLOR FldColor MOD 16, FldColor \ 16
CALL ENTERNUMBER (AFL#, "##", Msg$)
IF Msg$ <> "CR" THEN RETURN MainMenu
AnsLength = CINT (AFL#)
CALL QBox (CINT (CLin#), CINT (CCol#), Lins, Prompt$, AnsLength)
DELAY 2
COLOR FldColor MOD 16, FldColor \ 16
FOR I = 1 TO AnsLength
PRINT " ";
DELAY .03
NEXT
DELAY 1
CALL PressAKey
COLOR ScrColor MOD 16, ScrColor \ 16
CLS
RETURN
' ==================================================================
PrintDoc:
FileError = %False
N = 1
TopMargin = 4
BottomMargin = 6
IF NOT ColorDisplay THEN COLOR ScrColor MOD 16, ScrColor \ 16
CLS
CALL QBox (4, %Center, 1, "PRINTING DOCUMENTATION FILE", 0)
Header$ = ItalicPrtOn$ + _
" ALL-PURPOSE LIBRARY: THE DOC FILE (paginated automtically) Page " + _
ItalicPrtOff$
Footer$ = ""
L$ = "START"
CALL PRINTLINE (L$) ' Init printing -- disk or PRN -- and check
IF L$ <> "ABORTED BY USER" THEN
CALL SCREENPUSH
LOCATE 13, 1
IF NOT ColorDisplay THEN COLOR ScrColor MOD 16, ScrColor \ 16
PRINT " "
PRINT " NOTE: You may want to set your printer's front panel controls for the "
PRINT " font you prefer now. This routine sends no control codes to the "
PRINT " printer except some Esc-4 and Esc-5's to italicize the header, "
PRINT " so the printed output will be in the default font of your printer "
PRINT " otherwise. "
PRINT " "
PRINT " The All Purpose Library DOES support printer codes if you set it "
PRINT " up for your printer -- see the procedure Initialize (). "
PRINT " "
PRINT " CLICK A BUTTON OR PRESS A KEY TO START PRINTING. "
GOSUB ClickOrStrike
CALL SCREENPOP
IF NOT ColorDisplay THEN COLOR ScrColor MOD 16, ScrColor \ 16
File2View$ ="APLIB.DOC"
IF EXIST (File2View$) THEN ' uses function EXIST () ...
TxtFile = FREEFILE ' gets an available handle # ...
OPEN File2View$ FOR INPUT AS #TxtFile
Ln = 0
LOCATE 15,30: PRINT Esc2Q$
DO UNTIL EOF (TxtFile) OR FileError ' and views the file.
LINE INPUT #1, L$
INCR Ln
LOCATE 12,20
PRINT USING "PRINTING PAGE ## LINE ## ..."; Page%, CurrLine
CALL PRINTLINE (L$)
IF L$ = "ABORTED BY USER" THEN EXIT LOOP
LOOP
CALL PRINTLINE (CHR$ (12))
If SoundOn THEN PLAY ArribaBeep$
CLOSE ' close both files if 2 open
PLAY "L64 O2 C E G O3 C E G O4 C"
ELSE
CALL QBox (10,30,1,"DID NOT FIND FILE " + File2View$, 0)
END IF
CALL PressAKey
CLS
END IF
RETURN
' ((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((
MOFiles:
NextScrn2Pop = MainMenuScreen
CALL SCREENPOP
HomeDrive$ = GetCurrentDrive$
HomeDirec$ = CURDIR$ ("")
D2Search$ = PICKADIR$
IF D2Search$ = "" THEN RETURN
CALL QBox (4, 1, 1, CHR$(34) + D2Search$ + CHR$(34), 0)
F$ = PICKAFILE$ (D2Search$)
IF F$ <> "" THEN
INCR NextScrn2Pop
CALL SCREENPOP
CALL DirFirst (F$, FileSize&, DateCode&, TimeCode&)
$INCLUDE "FILEDATA.INC"
END IF
CALL PressAKey
RETURN
ScreenBlank:
RANDOMIZE TIMER
IF ColorDisplay THEN COLOR (17 + 5*RND), 0 _
ELSE COLOR %Gry + 16, %Blk
CLS ' clear screen ...
L = MAX ((21*RND), 1)
C = 25 + 20 * RND
LOCATE L, C, 0: PRINT "zzz ..."' ... and take a nap
GOSUB ClickOrStrike ' ... until click or keystroke.
GOTO MainMenu
HelpWindow:
CALL SCREENPUSH
CALL BOXMESSAGE (%Center, %Center, 1)
GOSUB ClickOrStrike
CALL SCREENPOP
COLOR FldColor MOD 16, FldColor \ 16
RETURN
MainMenuHelp:
DATA Press [E] for DEMO OF A DATA ENTRY WINDOW and the various formatted entry
DATA " Procedures in the All Purpose PB Programmers' Library. A window will
DATA " open onscreen and you can play w/ pick-list, string, number, date and
DATA " yes-or-no entries. It's a fake checking-program entry window.
DATA ""
DATA Press [F] for file commands -- you can list the source code file or the
DATA " documentation file to the screen; send the doc to your printer all
DATA " neatly paginated and stuff ... or shell out to DOS."
DATA ""
DATA "The [M] menu has four or five demonstrations of SUPERMENU including"
DATA " multi-page menus, PICKADIR$, and PICKAFILE$"
DATA ""
DATA "PRESS [O] for a few other doodads -- the Beep Development Environment,"
DATA " the exhaustive demo of Entry Modes, the Guess-your-Age Routine.
DATA ""
DATA THE QUIT MENU (Press Q) IS ALSO USED TO SWITCH SOME PROGRAM FUNCTIONS
DATA ""
DATA " BUTTONS: the first 3 are dummies / the 4th works;
DATA " type ALT-X or use the plastic pest to click on it
DATA ""
DATA " (to go on, press something)"
DATA END
'' ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■
'' ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■
$INCLUDE "APLIB-F.BAS"